package Login;

import java.util.Scanner;

/**
 * @BelongsProject: iobook
 * @BelongsPackage: Login
 * @Author: ByHappy  (Email:15188881427@163.c0m)
 * @CreateTime: 2023-08-05 16:41
 * @Description: TODO
 * @Version: 1.0
 **/
public class test {
    public static void main(String[] args) {
        UserDaoImpl udi = new UserDaoImpl();
        while (true) {
            System.out.println("-----欢迎来到登录注册页面------");
            System.out.println("1:注册");
            System.out.println("2:登录");
            System.out.println("3:退出系统");
            //创建用户操作类对象
            Scanner sc = new Scanner(System.in);
            String chioce = sc.nextLine();
            switch (chioce) {
                case "1":
                    System.out.println("欢迎来到注册页面");
                    System.out.println("请输入你的用户名");
                    String username = sc.nextLine();
                    System.out.println("请输入你的密码");
                    String password = sc.nextLine();
                    User user = new User(username, password);
                    udi.regist(user);
                    System.out.println("注册成功");
                    break;
                case "2":
                    System.out.println("欢迎来到登录页面");
                    System.out.println("请输入你的用户名");
                    String name1 = sc.nextLine();
                    System.out.println("请输入你的密码");
                    String Password = sc.nextLine();
                    boolean login = udi.isLogin(name1, Password);
                    if (login) {
                        System.out.println("登录成功");
                    }else {
                        System.out.println("登录失败");
                    }
                    break;
                case "3":
                default:
                    System.exit(0);
                    break;
            }
        }
    }
}
